# -*- coding: utf-8 -*-
from django.db.models import Q
from rest_framework import serializers

from app.emergency.models import MaterialAddress
from dvadmin.utils.json_response import SuccessResponse
from dvadmin.utils.serializers import CustomModelSerializer
from dvadmin.utils.viewset import CustomModelViewSet


class MaterialAddressSerializer(CustomModelSerializer):
    """
    物资存放点-序列化器
    """

    class Meta:
        model = MaterialAddress
        fields = "__all__"
        read_only_fields = ["id"]


class MaterialAddressCreateUpdateSerializer(CustomModelSerializer):
    """
    操作物资存放点  创建/更新时的列化器
    """

    class Meta:
        model = MaterialAddress
        fields = '__all__'


class MaterialAddressViewSet(CustomModelViewSet):
    """
    物资存放点接口
    list:查询
    create:新增
    update:修改
    retrieve:单例
    destroy:删除
    """
    queryset = MaterialAddress.objects.order_by('-create_datetime')
    serializer_class = MaterialAddressSerializer


